import { useEffect } from "react";
import { ArticleModelState, IRouteComponentProps, useDispatch, useSelector } from "umi";
import ImageViewer from "@/components/ImageViewer";

const articlePage: React.FC<IRouteComponentProps<{ id: string }>> = ({ match }) => {
  let { id } = match.params
  
  
  
  const { articleDetail } = useSelector((state: { article: ArticleModelState }) => state.article)

  let dispatch = useDispatch()
  useEffect(() => {
    dispatch({
      type: 'article/getArticleViewList',
      payload: id
    })
  }, [])
  return (
    <div>
      <ImageViewer>
        <img src={articleDetail.cover} alt="" />
        <div dangerouslySetInnerHTML={{ __html: articleDetail.html }}></div>
      </ImageViewer>

    </div>
  );
}
export default articlePage